package com.chagee.store.operation.server.generator;

/**
 * ClassName:SqlGenerator
 * Description:
 *
 * @date:2021/6/23 下午3:13
 * @author:yhl
 */
public class SqlGenerator {


//    public static void main(String[] args) {
//
//        geneCreateSql("demo", "event");
//
//        //geneDropSql("mp_limitation", "promotion_limit_instance");
//
//    }

    public static void geneCreateSql(String db, String table) {
        //db数量
        int dbCount = 3;
        //每个库表数量
        int perTableCount = 3;

        for (int i = 0; i <= dbCount; i++) {

            for (int j = 0; j <= perTableCount; j++) {
                //表index
                int index = (i * perTableCount) + j;

                // CREATE TABLE db_0.a_0
                //   LIKE mp_limitation_global.a ;

                System.out.println("CREATE TABLE " + db + "_" + i+"." + table +"_"+ index
                        + " LIKE demo_global." + table + " ;");

//                System.out.println("alter table " + db + "_" + i + "." +table+"_" + index + " change init_people_num int(10) COMMENT '初始参团人数';");


            }


        }
    }


    public static void geneDropSql(String db, String table) {
        //db数量
        int dbCount = 16;
        //每个库表数量
        int perTableCount = 32;

        for (int i = 0; i < dbCount; i++) {

            for (int j = 0; j < perTableCount; j++) {
                //表index
                int index = (i * perTableCount) + j;

                // drop table mp_limitation_0.promotion_limit_instance_0;

                System.out.println("drop table  " + db + "_" + i+"." + table  +"_"+ index + " ;");

            }


        }
    }


}
